package com.service.setting.impl;

import com.comm.R;
import com.comm.vo.HospitalinformationVo;
import com.entity.Hospitalinformation;
import com.entity.ShowDisposition;
import com.mapper.setting.SystemHospitalinformationMapper;
import com.service.setting.SystemHospitalinformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashSet;
import java.util.List;

@Service
public class SystemHospitalinformationServiceImpl implements SystemHospitalinformationService {


    @Autowired
    private SystemHospitalinformationMapper mapper;

    @Override
    public R fundHospitalinformation() {

        R r = new R();
        try {
            HospitalinformationVo hospitalinformation = mapper.fundHospitalinformation();
            r.setCode(200);
            r.setMsg("查到了");
            r.setData(hospitalinformation);
            r.setCount(1);
            return r;
        }catch (Exception e){
            r.setCode(500);
            r.setMsg("发生了一个莫名其妙的错误");
            return r;
        }
    }

    @Override
    public R addHospitalinformation(HospitalinformationVo vo) {
        R r = new R();
        try {
            int i = mapper.addHospitalinformation(vo);
            r.setCode(200);
            r.setMsg("修改成功");
            return r;

        }catch (Exception e){
            r.setCode(500);
            r.setMsg("发生了一个莫名其妙的错误");
            return r;
        }
    }

    @Override
    public R showDisposition() {
        R r = new R();
        ShowDisposition disposition = new ShowDisposition();

        try {

            HashSet<String> getdepartment = mapper.getdepartment();
            int doctorCount = mapper.getDoctorCount();
            disposition.setDepartment(getdepartment);
            disposition.setNumber(doctorCount);
            r.setCode(200);
            r.setMsg("查找成功");
            r.setData(disposition);
            return r;

        }catch (Exception e){
            e.printStackTrace();
            r.setCode(500);
            r.setMsg("发生了一个莫名其妙的错误");
            return r;
        }
    }
}
